import Common from '../../common/common.js';

/***
 *基础弹框类
 ***/
function BaseWin() {
    this.element;
    this.initElement();
    this.initBox();
}

BaseWin.prototype = {
    //初始化Element
    initElement: function () {
        this.element = Common.tool.createElement({
            props: {className: "mask"},
            tag: "mask",
            childNodes: [
                {
                    tag: "win",
                    props: {className: "win"},
                    childNodes: [
                        {
                            tag: "close",
                            label: "span",
                            props: {className: "close", innerText: "X"}
                        },
                        {
                            tag: "box",
                            props: {className: "box"}
                        },
                        {
                            tag: "buts",
                            props: {className: "buts"},
                            childNodes: [
                                {
                                    tag: "submit",
                                    label: "button",
                                    props: {innerText: "确定", type: "button", className: "submit"}
                                },
                                {
                                    tag: "cancel",
                                    label: "button",
                                    props: {innerText: "取消", type: "button", className: "cancel"}
                                }
                            ]
                        }
                    ]
                }
            ]
        });
        //绑定事件
        Common.tool.addHandle(this.element.win.buts.submit, "click", ()=>{this.submit()});
        Common.tool.addHandle(this.element.win.buts.cancel, "click", ()=>{this.cancel()});
        Common.tool.addHandle(this.element.win.close, "click", ()=>{this.cancel()});
    },
    //创建具体内容
    initBox: function () {
    },
    cancel: function () {
        this.delete();
    },
    submit: function () {

    },
    //创建
    create: function () {
        window.document.body.appendChild(this.element);
    },
    //删除
    delete: function () {
        window.document.body.removeChild(this.element)
    }
}

export default BaseWin;
